package com.ksyun.seckill.service.impl;

import com.ksyun.seckill.constants.SecKillImplVer;
import com.ksyun.seckill.service.SkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 无并发控制.
 *
 * @author ksc
 */
@Service
@Slf4j
public class SkServiceConcurrencyFreeControlV0 implements SkService {

    @Override
    public SecKillImplVer getSecKillImplVer() {
        return SecKillImplVer.V0;
    }

    @Override
    public Boolean haveOrder(Long campaignId, String phone) {
        return true;
    }

    @Override
    public void validateCampaign(Long campaignId) {
    }

    /**
     * 请思考：有什么问题呢？
     *
     * 超卖：生成了多余的订单.
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void secKill(Long campaignId, String phone, String path) {

    }


}
